function the_grid(com, grid)
{
	if(com == 'Select All')
    {
		$('.bDiv tbody tr',grid).addClass('trSelected');
    }
    
    if(com == 'De-select All')
    {
		$('.bDiv tbody tr',grid).removeClass('trSelected');
    }
	
	if(com.indexOf("New ") >= 0)
	{
		window.location = window.location.pathname + "/create/";
	}
	
	if(com == 'Batch Edit')
	{
		if($('.trSelected').length > 0)
		{
			var items = $('.trSelected');
			var itemlist = '';
			
			for(i = 0; i < items.length; i++)
			{
				if(itemlist)
				{
					itemlist += ":";
				}
				
				itemlist+= items[i].id.substr(3);
			}
			
			window.location = window.location.pathname + "/edit/" + itemlist + "/";
        }
		else
		{
			return false;
        }
	}
}

function delete_item(item, url)
{
	if(typeof url == 'undefined') url = window.location.pathname + "/del/";
	var info = item.split("|del|");
	
	if(confirm("Are you absolutely sure you want to delete the item:\n\n'" + info[1] + "'\n\nThis CANNOT be undone!"))
	{
		var items = $('.trSelected');
		
		$.ajax({
				type: "POST",
				url: url,
				data: "ids=" + info[0],
				success: function(data){
										$('#the_grid').flexReload();
										alert(data);
									   }
		});
	}
}